import pygame


class CountDownSprite(pygame.sprite.Sprite):
    def __init__(self, x, y, count):
        super().__init__()
        self.image = pygame.Surface((100, 100))
        self.image.fill((255, 255, 255))
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y

        font = pygame.font.Font("simsun.ttf", 30)
        surf = font.render(str(count), True, (0, 0, 0))
        surfRect = surf.get_rect()
        surfRect.center = (50, 65)
        self.image.blit(surf, surfRect)

        font = pygame.font.Font("simsun.ttf", 22)
        surf = font.render("游戏时间", True, (0, 0, 0))
        surfRect = surf.get_rect()
        surfRect.center = (50, 20)
        self.image.blit(surf, surfRect)



class CellSprite(pygame.sprite.Sprite):
    def __init__(self, x, y, shuduCell):
        super().__init__()
        self.shuduCell = shuduCell
        number = shuduCell.cell_value
        if number == 0:
            number = ""
        self.image = pygame.Surface((40, 40))
        self.image.fill((255, 255, 255))
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        self.renderNumber(number)

    def renderNumber(self,number):
        font = pygame.font.Font("simsun.ttf", 30)
        surf = font.render(str(number), True, (0, 0, 0))
        surfRect = surf.get_rect()
        surfRect.center = (20, 20)
        self.image.blit(surf, surfRect)
        pygame.display.flip()



class ButtonSprite(pygame.sprite.Sprite):
    def __init__(self, x, y, number):
        super().__init__()
        self.image = pygame.Surface((40, 40))
        self.image.fill((255, 255, 0))
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y

        font = pygame.font.Font("simsun.ttf", 30)
        surf = font.render(str(number), True, (0, 0, 0))
        surfRect = surf.get_rect()
        surfRect.center = (20, 20)
        self.image.blit(surf, surfRect)

